package org.onion.pattern.kit.validation.annotation.validator;

import org.onion.pattern.kit.validation.annotation.IsAsciiPrintable;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.apache.commons.lang3.StringUtils;


public class IsAsciiPrintableValidator implements ConstraintValidator<IsAsciiPrintable, String> {

    @Override
    public void initialize(IsAsciiPrintable isNumeric) {

    }

    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if (StringUtils.isBlank(s)) {
            return true;
        } else if (StringUtils.isAsciiPrintable(s)) {
            return true;
        }
        return false;
    }


}
